package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.macTestConPojo;
import com.example.pojo.macTestConValPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:macTestConMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/12/30 15:31
 * @Version 1.0
 */
@Mapper
public interface macTestConMapp {
    //    插入一行
    @DS("baodingRussia")
    @Insert("insert into macTestCon (" +
            "establishTime, updateTime, deleteSign," +
            " editName, workshop, drawing," +
            " op, project, requirement," +
            " testType, ceiling, lower," +
            " standard, frequency, department," +
            "projectCon, orderNumber, controlTesting) " +
            "VALUES (" +
            "#{establishTime}, #{updateTime}, #{deleteSign}," +
            " #{editName}, #{workshop}, #{drawing}," +
            " #{op}, #{project}, #{requirement}," +
            " #{testType}, #{ceiling}, #{lower}," +
            " #{standard}, #{frequency}, #{department}," +
            "#{projectCon}, #{orderNumber}, #{controlTesting})")
    void insertOne(macTestConPojo macTestConPojo);
    //输入三个字段，进行查询,适用查询的是三个字符串格式的数据
    @DS("baodingRussia")
    @Select("select * from macTestCon where ${firstFieldName}=#{firstFieldVal} and ${secondFieldName}=#{secondFieldVal} and ${thirdName}=#{thirdVal} and deleteSign=1")
    List<macTestConPojo> inquiryThreeField(String firstFieldName, String firstFieldVal, String secondFieldName, String secondFieldVal, String thirdName, String thirdVal);
    //输入四个字段，进行查询,适用查询的是四个字符串格式的数据
    @DS("baodingRussia")
    @Select("select * from macTestCon where ${firstFieldName}=#{firstFieldVal} and ${secondFieldName}=#{secondFieldVal} and ${thirdName}=#{thirdVal} and ${fourthFieldName}=#{fourthFiledVal} and deleteSign=1")
    List<macTestConPojo> inquiryFourthField(String firstFieldName, String firstFieldVal, String secondFieldName, String secondFieldVal, String thirdName, String thirdVal, String fourthFieldName, String fourthFiledVal);
    //根据id，修改一整行。
    @DS("baodingRussia")
    @Update("UPDATE macTestCon SET " +
            "updateTime = #{macTestConPojo.updateTime}, " +
            "deleteSign = #{macTestConPojo.deleteSign}, " +
            "editName = #{macTestConPojo.editName}, " +
            "workshop = #{macTestConPojo.workshop}, " +
            "drawing = #{macTestConPojo.drawing}, " +
            "op = #{macTestConPojo.op}, " +
            "project = #{macTestConPojo.project}, " +
            "requirement = #{macTestConPojo.requirement}, " +
            "testType = #{macTestConPojo.testType}, " +
            "ceiling = #{macTestConPojo.ceiling}, " +
            "lower = #{macTestConPojo.lower}, " +
            "standard = #{macTestConPojo.standard}, " +
            "frequency = #{macTestConPojo.frequency}, " +
            "department = #{macTestConPojo.department}, " +
            "orderNumber = #{macTestConPojo.orderNumber}, " +
            "controlTesting = #{macTestConPojo.controlTesting} " +
            "WHERE id = #{id}")
    void editOne(Integer id, macTestConPojo macTestConPojo);
    //修改一个字段.依据id
    @DS("baodingRussia")
    @Update("update macTestCon set ${firstFieldName}=#{firstFieldVal} and updateTime=#{updateTime} where id=#{id}")
    void oneField(Integer id, String firstFieldName, Integer firstFieldVal, LocalDateTime updateTime);
    //一次插入多行检测数据
    @DS("russianEngine")
    void testValMacTestCon(List<macTestConValPojo> macTestConValPojos);
    //没有特性值，按照三个特性和一个最近数量筛选
    @DS("russianEngine")
    @Select("select * from mac_test_con_val where ${firstFieldName}=#{firstFieldVal} and ${secondFieldName}=#{secondFieldVal} and ${thirdName}=#{thirdVal} and deleteSign=1 ORDER by testDate desc limit #{fifthVal}")
    List<macTestConValPojo> macTestConValInquiryFourField(String firstFieldName, String firstFieldVal, String secondFieldName, String secondFieldVal, String thirdName, String thirdVal, int fifthVal);
    //有特性值，按照四个特性和一个最近数量筛选
    @DS("russianEngine")
    @Select("select * from mac_test_con_val where ${firstFieldName}=#{firstFieldVal} and ${secondFieldName}=#{secondFieldVal} and ${thirdName}=#{thirdVal} and  ${fourthName}=#{fourthVal} and deleteSign=1 ORDER by testDate desc limit #{fifthVal}")
    List<macTestConValPojo> macTestConValInquiryFiveField(String firstFieldName, String firstFieldVal, String secondFieldName, String secondFieldVal, String thirdName, String thirdVal, String fourthName, String fourthVal, int fifthVal);
}
